#ifndef H_NET_ERROR_CODE_H
#define H_NET_ERROR_CODE_H

#if _WIN32
#include <WinSock2.h>
#else
#include <errno.h>
#endif

namespace TB
{
	enum class ENetErrorCode
	{
#if _WIN32
		//     An unspecified System.Net.Sockets.Socket error has occurred.
		SocketError = -1,
		//     The System.Net.Sockets.Socket operation succeeded.
		Success = 0,
		//     The overlapped operation was aborted due to the closure of the System.Net.Sockets.Socket.
		OperationAborted = WSA_OPERATION_ABORTED,
		//     The application has initiated an overlapped operation that cannot be completed
		//     immediately.
		IOPending = WSA_IO_PENDING,
		//     A blocking System.Net.Sockets.Socket call was canceled.
		Interrupted = WSAEINTR,
		//     An attempt was made to access a System.Net.Sockets.Socket in a way that is forbidden
		//     by its access permissions.
		AccessDenied = WSAEACCES,
		//     An invalid pointer address was detected by the underlying socket provider.
		Fault = WSAEFAULT,
		//     An invalid argument was supplied to a System.Net.Sockets.Socket member.
		InvalidArgument = WSAEINVAL,
		//     There are too many open sockets in the underlying socket provider.
		TooManyOpenSockets = WSAEMFILE,
		//     An operation on a nonblocking socket cannot be completed immediately.
		WouldBlock = WSAEWOULDBLOCK,
		//     A blocking operation is in progress.
		InProgress = WSAEINPROGRESS,
		//     The nonblocking System.Net.Sockets.Socket already has an operation in progress.
		AlreadyInProgress = WSAEALREADY,
		//     A System.Net.Sockets.Socket operation was attempted on a non-socket.
		NotSocket = WSAENOTSOCK,
		//     A required address was omitted from an operation on a System.Net.Sockets.Socket.
		DestinationAddressRequired = WSAEDESTADDRREQ,
		//     The datagram is too long.
		MessageSize = WSAEMSGSIZE,
		//     The protocol type is incorrect for this System.Net.Sockets.Socket.
		ProtocolType = WSAEPROTOTYPE,
		//     An unknown, invalid, or unsupported option or level was used with a System.Net.Sockets.Socket.
		ProtocolOption = WSAENOPROTOOPT,
		//     The protocol is not implemented or has not been configured.
		ProtocolNotSupported = WSAEPROTONOSUPPORT,
		//     The support for the specified socket type does not exist in this address family.
		SocketNotSupported = WSAESOCKTNOSUPPORT,
		//     The address family is not supported by the protocol family.
		OperationNotSupported = WSAEOPNOTSUPP,
		//     The protocol family is not implemented or has not been configured.
		ProtocolFamilyNotSupported = WSAEPFNOSUPPORT,
		//     The address family specified is not supported. This error is returned if the
		//     IPv6 address family was specified and the IPv6 stack is not installed on the
		//     local machine. This error is returned if the IPv4 address family was specified
		//     and the IPv4 stack is not installed on the local machine.
		AddressFamilyNotSupported = WSAEAFNOSUPPORT,
		//     Only one use of an address is normally permitted.
		AddressAlreadyInUse = WSAEADDRINUSE,
		//     The selected IP address is not valid in this context.
		AddressNotAvailable = WSAEADDRNOTAVAIL,
		//     The network is not available.
		NetworkDown = WSAENETDOWN,
		//     No route to the remote host exists.
		NetworkUnreachable = WSAENETUNREACH,
		//     The application tried to set System.Net.Sockets.SocketOptionName.KeepAlive on
		//     a connection that has already timed out.
		NetworkReset = WSAENETRESET,
		//     The connection was aborted by the .NET Framework or the underlying socket provider.
		ConnectionAborted = WSAECONNABORTED,
		//     The connection was reset by the remote peer.
		ConnectionReset = WSAECONNRESET,
		//     No free buffer space is available for a System.Net.Sockets.Socket operation.
		NoBufferSpaceAvailable = WSAENOBUFS,
		//     The System.Net.Sockets.Socket is already connected.
		IsConnected = WSAEISCONN,
		//     The application tried to send or receive data, and the System.Net.Sockets.Socket
		//     is not connected.
		NotConnected = WSAENOTCONN,
		//     A request to send or receive data was disallowed because the System.Net.Sockets.Socket
		//     has already been closed.
		Shutdown = WSAESHUTDOWN,
		//     The connection attempt timed out, or the connected host has failed to respond.
		TimedOut = WSAETIMEDOUT,
		//     The remote host is actively refusing a connection.
		ConnectionRefused = WSAECONNREFUSED,
		//     The operation failed because the remote host is down.
		HostDown = WSAEHOSTDOWN,
		//     There is no network route to the specified host.
		HostUnreachable = WSAEHOSTUNREACH,
		//     Too many processes are using the underlying socket provider.
		ProcessLimit = WSAEPROCLIM,
		//     The network subsystem is unavailable.
		SystemNotReady = WSASYSNOTREADY,
		//     The version of the underlying socket provider is out of range.
		VersionNotSupported = WSAVERNOTSUPPORTED,
		//     The underlying socket provider has not been initialized.
		NotInitialized = WSANOTINITIALISED,
		//     A graceful shutdown is in progress.
		Disconnecting = WSAEDISCON,
		//     The specified class was not found.
		TypeNotFound = WSATYPE_NOT_FOUND,
		//     No such host is known. The name is not an official host name or alias.
		HostNotFound = WSAHOST_NOT_FOUND,
		//     The name of the host could not be resolved. Try again later.
		TryAgain = WSATRY_AGAIN,
		//     The error is unrecoverable or the requested database cannot be located.
		NoRecovery = WSANO_RECOVERY,
		//     The requested name or IP address was not found on the name server.
		NoData = WSANO_DATA
#else
		//     An unspecified System.Net.Sockets.Socket error has occurred.
		SocketError = -1,
		//     The System.Net.Sockets.Socket operation succeeded.
		Success = 0,
		//     The overlapped operation was aborted due to the closure of the System.Net.Sockets.Socket.
		OperationAborted = ECANCELED,
		//     The application has initiated an overlapped operation that cannot be completed
		//     immediately.
		IOPending = EINPROGRESS,
		//     A blocking System.Net.Sockets.Socket call was canceled.
		Interrupted = EINTR,
		//     An attempt was made to access a System.Net.Sockets.Socket in a way that is forbidden
		//     by its access permissions.
		AccessDenied = EACCES,
		//     An invalid pointer address was detected by the underlying socket provider.
		Fault = EFAULT,
		//     An invalid argument was supplied to a System.Net.Sockets.Socket member.
		InvalidArgument = EINVAL,
		//     There are too many open sockets in the underlying socket provider.
		TooManyOpenSockets = EMFILE,
		//     An operation on a nonblocking socket cannot be completed immediately.
		WouldBlock = EAGAIN,
		//     A blocking operation is in progress.
		InProgress = EINPROGRESS,
		//     The nonblocking System.Net.Sockets.Socket already has an operation in progress.
		AlreadyInProgress = EALREADY,
		//     A System.Net.Sockets.Socket operation was attempted on a non-socket.
		NotSocket = ENOTSOCK,
		//     A required address was omitted from an operation on a System.Net.Sockets.Socket.
		DestinationAddressRequired = EDESTADDRREQ,
		//     The datagram is too long.
		MessageSize = EMSGSIZE,
		//     The protocol type is incorrect for this System.Net.Sockets.Socket.
		ProtocolType = EPROTOTYPE,
		//     An unknown, invalid, or unsupported option or level was used with a System.Net.Sockets.Socket.
		ProtocolOption = ENOPROTOOPT,
		//     The protocol is not implemented or has not been configured.
		ProtocolNotSupported = EPROTONOSUPPORT,
		//     The support for the specified socket type does not exist in this address family.
		SocketNotSupported = ESOCKTNOSUPPORT,
		//     The address family is not supported by the protocol family.
		OperationNotSupported = ENOTSUP,
		//     The protocol family is not implemented or has not been configured.
		ProtocolFamilyNotSupported = EPFNOSUPPORT,
		//     The address family specified is not supported. This error is returned if the
		//     IPv6 address family was specified and the IPv6 stack is not installed on the
		//     local machine. This error is returned if the IPv4 address family was specified
		//     and the IPv4 stack is not installed on the local machine.
		AddressFamilyNotSupported = EAFNOSUPPORT,
		//     Only one use of an address is normally permitted.
		AddressAlreadyInUse = EADDRINUSE,
		//     The selected IP address is not valid in this context.
		AddressNotAvailable = EADDRNOTAVAIL,
		//     The network is not available.
		NetworkDown = ENETDOWN,
		//     No route to the remote host exists.
		NetworkUnreachable = ENETUNREACH,
		//     The application tried to set System.Net.Sockets.SocketOptionName.KeepAlive on
		//     a connection that has already timed out.
		NetworkReset = ENETRESET,
		//     The connection was aborted by the .NET Framework or the underlying socket provider.
		ConnectionAborted = ECONNABORTED,
		//     The connection was reset by the remote peer.
		ConnectionReset = ECONNRESET,
		//     No free buffer space is available for a System.Net.Sockets.Socket operation.
		NoBufferSpaceAvailable = ENOBUFS,
		//     The System.Net.Sockets.Socket is already connected.
		IsConnected = EISCONN,
		//     The application tried to send or receive data, and the System.Net.Sockets.Socket
		//     is not connected.
		NotConnected = ENOTCONN,
		//     A request to send or receive data was disallowed because the System.Net.Sockets.Socket
		//     has already been closed.
		Shutdown = EPIPE,
		//     The connection attempt timed out, or the connected host has failed to respond.
		TimedOut = ETIMEDOUT,
		//     The remote host is actively refusing a connection.
		ConnectionRefused = ECONNREFUSED,
		//     The operation failed because the remote host is down.
		HostDown = EHOSTDOWN,
		//     There is no network route to the specified host.
		HostUnreachable = EHOSTUNREACH,
		//     Too many processes are using the underlying socket provider.
		//ProcessLimit = 10067,
		//     The network subsystem is unavailable.
		//SystemNotReady = 10091,
		//     The version of the underlying socket provider is out of range.
		//VersionNotSupported = 10092,
		//     The underlying socket provider has not been initialized.
		//NotInitialized = 10093,
		//     A graceful shutdown is in progress.
		Disconnecting = ESHUTDOWN,
		//     The specified class was not found.
		//TypeNotFound = 10109,
		//     No such host is known. The name is not an official host name or alias.
		HostNotFound = ENXIO, // not perfect, but closest match available
		//     The name of the host could not be resolved. Try again later.
		TryAgain = EAGAIN,
		//     The error is unrecoverable or the requested database cannot be located.
		//NoRecovery = 11003,
		//     The requested name or IP address was not found on the name server.
		NoData = ENODATA
#endif
	};
}

#endif
